<template>
	<view class="indexs">
		<view class="header header_lan" :style="'padding-top: ' + navH + 'px;'">
			<view class="header_height"
				:style="'height:' + gaodu + 'px;line-height:' + gaodu + 'px;top:' + gaodutops + 'px;'">
				<view class="index_h_cont3">
					<view class="index_wenben_img" @tap="jumpzuo">
						<image :src="imgUrl + '/dzx_img22.png'" mode="widthFix"></image>
					</view>
					<view class="index_wenben baise">{{ $t('page_dairuku.searchResult') }}</view>
				</view>
			</view>
			<view class="coloe_title">s</view>
		</view>
		<view class="index_center" :style="'padding-top:' + (navH + 50) + 'px;'">
			<view class="chaxunjieguo_center">
				<view class="shenqingdb_item1">
					<view class="shenqingdb_item1_txt">
						<image :src="imgUrl + '/dzx_img34.png'"></image>
						<text>{{ $t('page_dairuku.hint') }}</text>
					</view>
				</view>
				<view class="chaxunjieguo_item1">
					<view class="chaxunjieguo_item1_t1">
						<image :src="imgUrl + '/dzx_img27.png'"></image>
						<text>{{ $t('page_dairuku.shipping_information') }}</text>
					</view>
					<view class="chaxunjieguo_item1_t2">
						{{ optionsdata.guojianame }}/{{ optionsdata.weigth }}{{ optionsdata.freeType==1?"CBM":weight_mode.unit }}/{{ optionsdata.length }}{{ setting.size_mode.unit }}/{{ optionsdata.width
						}}{{ setting.size_mode.unit }}/{{ optionsdata.height }}{{ setting.size_mode.unit }}
					</view>
				</view>
				<view class="shenqingdb_item1_list" v-if="arrlist.length != 0">
					<view class="shenqingdb_item1_cont" @tap="gojiyunxq" :data-id="item.id"
						:data-weight="item.predict.weight" :data-yprice="item.predict.price"
						:data-price="item.sortprice" :data-service="item.service" v-for="(item, index) in arrlist"
						:key="index">
						<view class="shenqingdb_item1_cont_l">
							<image :src="item.image ? item.image.file_path : ''" mode="aspectFill"></image>
						</view>

						<view class="shenqingdb_item1_cont_r">
							<view class="shenqingdb_item1_t3">
								<text>{{ item.name }}</text>
								<image :src="imgUrl + '/dzx_img42.png'"></image>
							</view>
							<view class="shenqingdb_item1_t4">
								{{ $t('page_dairuku.estimated_freight') }}
								<text>{{ item.predict.price == $t('page_other.无法预估价格')? item.predict.price : price_mode.unit + item.sortprice }}</text>
							</view>
							<view class="shenqingdb_item1_t4">
								{{ $t('page_dairuku.time_delivery') }}
								<text>{{ item.limitationofdelivery }}</text>
							</view>
							<view class="shenqingdb_item1_t4">
								{{ $t('page_dairuku.chargeable_weight') }}
								<text>{{ item.predict.weight }}{{ item.line_type == 1 ? 'CBM' : item.line_type_unit_name }}</text>
							</view>
						</view>
					</view>
				</view>
				<view class="shenqingdb_item1_list" v-else>
					<view class="my_dingdan_zanwu">
						<image :src="imgUrl + '/dzx_img43.png'"></image>
						<text>{{ $t('page_dairuku.route_not_found') }}</text>
					</view>
				</view>
			</view>
			
			
			<view class="index_item4" v-if="setting.is_line_show==1 && zuijiaxianlu.length>0">
				<view class="index_item4_title">
					<view class="index_item4_l">
						<image :src="imgUrl + '/dzx_img14.png'"></image>
						<text>{{ $t('page_index.allRoute') }}</text>
					</view>
				</view>
				<view :class="'index_item4_list index_list_heji' + index">
					<view class="index_item4_cont" @tap="goluxian" :data-yprice="items.price"  :data-price="items.price" :data-weight="optionsdata.weigth" :data-id="items.id" v-for="(items, index1) in zuijiaxianlu" :key="index1">
						<view class="index_item4_cont_l"><image :src="items.image?items.image.file_path:''" mode="aspectFill"></image></view>

						<view class="index_item4_cont_r">
							<view class="index_item4_cont_r_t1">
								{{ items.name }}({{ $t('page_index.aging') }}：{{ items.limitationofdelivery }})
							</view>
							<view class="index_item4_cont_r_dis">
								<!--      <view class="index_item4_cont_r_t2">
									时效：
									<text>{{ items.limitationofdelivery }}天</text>
								</view> -->
								<view class="index_item4_cont_r_t2">
									{{ $t('page_index.tariff') }}：
									<text>{{ items.tariff }}</text>
								</view>
							</view>
							<view class="index_item4_cont_r_t2">{{ $t('page_index.lineCharacteristics') }}：{{ items.line_special }}</view>
						</view>
					</view>
				</view>
			</view>
			
			
		</view>
	</view>
</template>

<script>
	// pages/shouye/shouye_zkc/shouye_zkc.js
	const app = getApp();

	let request = require('../../../utils/require');

	export default {
		data() {
			return {
				navH: app.globalData.navHeight,
				gaodu: app.globalData.height,
				gaodutops: app.globalData.top,
				imgUrl: app.globalData.imgUrl,
				arrlist: [],
				freeType:'',
				urlimg: app.globalData.urlimg,
				weight_mode: uni.getStorageSync('weight_mode'),
				price_mode: uni.getStorageSync('price_mode'),
				setting: uni.getStorageSync('setting'),
				zuijiaxianlu:[],
				optionsdata: {
					guojianame: '',
					weigth: '',
					length: '',
					width: '',
					height: ''
				}
			};
		},
		/**
		 * 生命周期函数--监听页面加载
		 */
		onLoad(options) {
			var that = this;
			var optionsdata = JSON.parse(options.data);
			that.optionsdata = optionsdata
			that.chaxunlist();
			console.log(optionsdata, 'data');
		},
		onShow() {
			var that = this;
			that.getAllline();
		},
		/**
		 * 生命周期函数--监听页面初次渲染完成
		 */
		onReady: function() {},
		/**
		 * 生命周期函数--监听页面隐藏
		 */
		onHide: function() {},
		/**
		 * 生命周期函数--监听页面卸载
		 */
		onUnload: function() {},
		/**
		 * 页面相关事件处理函数--监听用户下拉动作
		 */
		onPullDownRefresh: function() {},
		/**
		 * 页面上拉触底事件的处理函数
		 */
		onReachBottom: function() {},
		/**
		 * 用户点击右上角分享
		 */
		onShareAppMessage: function() {},
		methods: {
			goluxian(e) {
				console.log(e,9896)
				uni.navigateTo({
					url: '/pages/indexs/jiyunxinxi/jiyunxinxi?id=' + e.currentTarget.dataset.id + '&weight=' +
						e.currentTarget.dataset.weight + '&yprice=' +
						e.currentTarget.dataset.yprice + '&price=' +
						e.currentTarget.dataset.price 
				});
			},
			gojiyunxq(e) {
				uni.navigateTo({
					url: '/pages/indexs/jiyunxinxi/jiyunxinxi?id=' +
						e.currentTarget.dataset.id +
						'&price=' +
						e.currentTarget.dataset.price +
						'&weight=' +
						e.currentTarget.dataset.weight +
						'&service=' +
						e.currentTarget.dataset.service +
						'&yprice=' +
						e.currentTarget.dataset.yprice
				});
			},

			jumpzuo() {
				uni.navigateBack();
			},

			chaxunlist() {
				var that = this;
				var data = {
					token: uni.getStorageSync('token'),
					length: that.optionsdata.length,
					weigth: that.optionsdata.weigth,
					width: that.optionsdata.width,
					country_id: that.optionsdata.country_id,
					freeType: that.optionsdata.freeType,
					class_ids: that.optionsdata.class_ids,
					height: that.optionsdata.height,
					service: that.optionsdata.service,
					linecategory:that.optionsdata.linecategory,
				};
				request.post(`index.php?s=/api/page/getfree&wxapp_id=` + uni.getStorageSync('web_id'), data).then(res => {
					if (res.data.code == 1) {
						that.arrlist = res.data.data
						console.log(res.data.data, 're???'); // setTimeout(() => {
						// }, 1000);
					} else {}
				});
			},
			
			getAllline(){
				var that = this;
				console.log(that.optionsdata,99);
				var data = {
					token: uni.getStorageSync('token'),
					country_id:that.optionsdata.country_id,
					weigth: that.optionsdata.weigth,
				};
				//最佳线路
				request.get(`index.php?s=/api/page/getAllline&wxapp_id=` + uni.getStorageSync('web_id'), data).then(res => {
					if (res.data.code == 1) {
						that.zuijiaxianlu = res.data.data
					}
				}); 
			}
			
		}
	};
</script>
<style>
	@import './chaxunjieguo.css';
</style>